#include <iostream>
using namespace std;
typedef struct Node* PtrToNode;
typedef int Elemtype;
struct Node
{
	Elemtype data;
	PtrToNode Next;
};

void main()
{
	int dimn;
	PtrToNode head = NULL, mart = NULL;
	head->Next = mart;
	mart = (PtrToNode)malloc(sizeof(Node));
	mart->Next = NULL;
	int mul;
	cout << "Please input the dimension of the matrix: ";
	cin >> dimn;
	cout << "Please input the elements of the matrix: ";
	for (int i = 0; i<dimn*dimn; i++)
	{
		cin >> mart->data;
		mart = mart->Next;
	}
	mart = head->Next;
	cout << "The original matrix you input is:" << endl;
	for (int i = 0; i<dimn*dimn; i++)
	{
		cout << mart->data << " ";
		mart = mart->Next;
		if ((i + 1) % dimn == 0)
			cout << endl;
	}
	mart = head->Next;
	cout << endl << "Please input the number that will multiply the matrix:";
	cin >> mul;
	for (int i = 0; i<dimn*dimn; i++)
	{
		mart->data *= mul;
		mart = mart->Next;
	}
	cout << "The matrix multiplied by the number is:" << endl;
	for (int i = 0; i<dimn*dimn; i++)
	{
		cout << mart->data << " ";
		mart = mart->Next;
		if ((i + 1) % dimn == 0)
			cout << endl;
	}
	free(mart);
	system("pause");
}